<?php

namespace App\HttpController;

use App\Service\ConfigureService;
use EasySwoole\HttpAnnotation\AnnotationTag\Api;
use EasySwoole\HttpAnnotation\AnnotationTag\ApiDescription;
use EasySwoole\HttpAnnotation\AnnotationTag\ApiGroup;
use EasySwoole\HttpAnnotation\AnnotationTag\ApiSuccess;
use EasySwoole\HttpAnnotation\AnnotationTag\Method;
use EasySwoole\HttpAnnotation\AnnotationTag\Param;
use EasySwoole\ORM\Exception\Exception;
use Throwable;

/**
 * @ApiGroup(groupName="配置信息")
 */
class Configure extends BaseController
{
    /**
     * @Api(name="获取房屋配置", path="/configure/getHouse", version="1.0.0")
     * @ApiDescription(value="获取房屋配置")
     * @Method(allow={POST})
     * @Param(name="nid", required="", description="上级id， 默认0", from={JSON})
     * @ApiSuccess({"code": 200, "msg": "获取成功", "result": [{"id": 1,"name": "龍舟壹号院"},{"id": 10,"name": "龍舟贰号院"}]})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getHouse($nid): bool
    {
        $res = ConfigureService::getInstance()->getHouse($nid);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取报修类型", path="/configure/getRepairType", version="1.0.0")
     * @ApiDescription(value="获取报修类型")
     * @Method(allow={POST})
     * @Param(name="type", defaultValue="0",description="类型0.户内，1.公区",from={JSON})
     * @ApiSuccess({"code": 200, "msg": "获取成功", "result": [{"id": 1,"icon": "https://s4.ax1x.com/2022/02/23/b9WaRI.png","name": "管道疏通","title": "管道疏通"}]})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getRepairType($type): bool
    {
        $res = ConfigureService::getInstance()->getRepairType($type);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取报修详情", path="/configure/getRepairDetail", version="1.0.0")
     * @ApiDescription(value="获取报修详情")
     * @Method(allow={POST})
     * @Param(name="rid", required="", description="上级id， 默认0", from={JSON})
     * @ApiSuccess({"code": 200, "msg": "获取成功", "result": [{"id": 1,"icon": "https://s4.ax1x.com/2022/02/23/b9WaRI.png","promise": "'上门维修或检查时，上门维修或检查时，上门维修或检查时，上门维修或检查时，上门维修或检查时，',\r\n\t\t\t\t\t'上门维修或检查时，上门维修或检查时，上门维修或检查时，上门维修或检查时，上门维修或检查时，',\r\n\t\t\t\t\t'上门维修或检查时，上门维修或检查时，上门维修或检查时，上门维修或检查时，上门维修或检查时',\r\n\t\t\t\t\t'上门维修或检查时，上门维修或检查，',\r\n\t\t\t\t\t'上门维修或检查时',","description": "'上门维修或检查时，上门维修或检查时，上门维修或检查时，上门维修或检查时，上门维修或检查时，',\r\n\t\t\t\t\t'上门维修或检查时，上门维修或检查时，上门维修或检查时，上门维修或检查时，上门维修或检查时，',\r\n\t\t\t\t\t'上门维修或检查时，上门维修或检查时，上门维修或检查时，上门维修或检查时，上门维修或检查时',\r\n\t\t\t\t\t'上门维修或检查时，上门维修或检查，',\r\n\t\t\t\t\t'上门维修或检查时',","is_deleted": 0,"create_time": 0,"update_time": 0,"project": [{"name": "地漏疏通","price": 80,"unit": "个","memo": "1"},{"name": "面彭疏通","price": 80,"unit": "个","memo": "32"},{"name": "洗手盆疏通","price": 80,"unit": "个","memo": "23"}]}]})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getRepairDetail($rid): bool
    {
        $res = ConfigureService::getInstance()->getRepairDetail($rid);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取首页导航", path="/configure/getHomeNav", version="1.0.0")
     * @ApiDescription(value="获取首页导航")
     * @Method(allow={POST})
     * @ApiSuccess({"code": 200,"result": [{"id": 1,"name": "访客通行","icon": "https://s4.ax1x.com/2022/02/17/H56Cwt.gif"},{"id": 2,"name": "生活缴费","icon": "https://s4.ax1x.com/2022/02/22/HzVaGj.png"},{"id": 3,"name": "报事报修","icon": "https://s4.ax1x.com/2022/02/22/HzVBMq.png"},{"id": 4,"name": "智慧停车","icon": "https://s4.ax1x.com/2022/02/22/HzVDs0.png"},{"id": 5,"name": "龙庭管家","icon": "https://s4.ax1x.com/2022/02/22/HzVwzn.png"},{"id": 6,"name": "龙庭社圈","icon": "https://s4.ax1x.com/2022/02/22/HzVrLV.png"},{"id": 7,"name": "无忧社区","icon": "https://s4.ax1x.com/2022/02/22/HzVtIg.png"},{"id": 8,"name": "邻里商城","icon": "https://s4.ax1x.com/2022/02/22/HzVdRs.png"}],"msg": "获取成功"})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getHomeNav(): bool
    {
        $res = ConfigureService::getInstance()->getHomeNav();
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取邻享栏目", path="/configure/getAdjacentNav", version="1.0.0")
     * @ApiDescription(value="获取邻享栏目")
     * @Method(allow={POST})
     * @ApiSuccess({"code": 200,"result": [{"id": 1,"name": "四点半课堂","icon": "https://s4.ax1x.com/2022/03/03/bY2H9f.png","image": "https://s4.ax1x.com/2022/02/17/H56ZlQ.gif"},{"id": 2,"name": "共享格子铺","icon": "https://s4.ax1x.com/2022/03/03/bY2T4P.png","image": "https://s4.ax1x.com/2022/02/17/H53wnJ.png"},{"id": 3,"name": "共享便民","icon": "https://s4.ax1x.com/2022/03/03/bY2oNt.png","image": "https://s1.ax1x.com/2022/03/07/bsImB4.jpg"},{"id": 4,"name": "共享养老","icon": "https://s4.ax1x.com/2022/03/03/bY2b38.png","image": "https://s4.ax1x.com/2022/03/04/bN6OBj.png"},{"id": 5,"name": "共享厨房","icon": "","image": "https://s4.ax1x.com/2022/02/17/H5aAWn.png"}],"msg": "获取成功"})
     * @return bool
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getAdjacentNav(): bool
    {
        $res = ConfigureService::getInstance()->getAdjacentNav();
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取轮播图", path="/configure/getBanner", version="1.0.0")
     * @ApiDescription(value="获取轮播图")
     * @Method(allow={POST})
     * @Param(name="type", description="类型:0.首页，1.邻享，2.商城，3.社圈", defaultValue="0", from={JSON})
     * @ApiSuccess({"code": 200,"result": [{"id": 1,"type": 0,"title": "龙海智慧物业","author": "","image": "https://s4.ax1x.com/2022/02/17/H56eyj.png","content": "","is_deleted": 0,"create_time": 0,"update_time": 0}],"msg": "获取成功"})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getBanner($type): bool
    {
        $res = ConfigureService::getInstance()->getBanner($type);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取快捷功能", path="/configure/getOneKey", version="1.0.0")
     * @ApiDescription(value="获取快捷功能")
     * @Method(allow={POST})
     * @ApiSuccess({"code": 200,"result": [{"id": 1,"name": "开门","icon": "https://s1.ax1x.com/2022/03/08/bcADk4.png","image": "","description": "","is_deleted": 0,"create_time": 0,"update_time": 0},{"id": 2,"name": "电梯","icon": "https://s1.ax1x.com/2022/03/08/bcAc11.png","image": "","description": "","is_deleted": 0,"create_time": 0,"update_time": 0},{"id": 3,"name": "停车","icon": "https://s1.ax1x.com/2022/03/08/bcArtJ.png","image": "","description": "","is_deleted": 0,"create_time": 0,"update_time": 0},{"id": 4,"name": "巡查","icon": "https://s1.ax1x.com/2022/03/08/bcAsh9.png","image": "","description": "","is_deleted": 0,"create_time": 0,"update_time": 0},{"id": 5,"name": "客服","icon": "https://s1.ax1x.com/2022/03/08/bcAg6x.png","image": "","description": "","is_deleted": 0,"create_time": 0,"update_time": 0}],"msg": "获取成功"})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getOneKey(): bool
    {
        $res = ConfigureService::getInstance()->getOneKey();
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取邻享服务", path="/configure/getShareService", version="1.0.0")
     * @ApiDescription(value="获取邻享服务")
     * @Method(allow={POST})
     * @Param(name="id", required="", description="服务类目id", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getShareService($id): bool
    {
        $res = ConfigureService::getInstance()->getShareService($id);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取轮播文章", path="/configure/getArticle", version="1.0.0")
     * @ApiDescription(value="获取轮播文章")
     * @Method(allow={POST})
     * @Param(name="id", required="", description="id", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getArticle($id): bool
    {
        $res = ConfigureService::getInstance()->getArticle($id);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取便民服务", path="/configure/getFreeService", version="1.0.0")
     * @ApiDescription(value="获取便民服务")
     * @Method(allow={POST})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getFreeService(): bool
    {
        $res = ConfigureService::getInstance()->getFreeService();
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取巡查设备", path="/configure/getPatrol", version="1.0.0")
     * @ApiDescription(value="获取巡查设备")
     * @Method(allow={POST})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getPatrol(): bool
    {
        $res = ConfigureService::getInstance()->getPatrol();
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取商城分类导航多列", path="/configure/getShopNavS", version="1.0.0")
     * @ApiDescription(value="获取商城分类导航多列")
     * @Method(allow={POST})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getShopNavS(): bool
    {
        $res = ConfigureService::getInstance()->getShopNavS();
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取商城分类导航热门推荐分类", path="/configure/getShopNavH", version="1.0.0")
     * @ApiDescription(value="获取商城分类导航热门推荐分类")
     * @Method(allow={POST})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getShopNavH(): bool
    {
        $res = ConfigureService::getInstance()->getShopNavH();
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="咨询开关", path="/configure/newsConfig", version="1.0.0")
     * @ApiDescription(value="咨询开关")
     * @Method(allow={POST})
     * @return bool
     */
    public function newsConfig(): bool
    {
        $res = [
            'result' => true,
            'msg' => '已开通'
        ];
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'] ?? 'success', $res['msg']);
    }

    /**
     * @Api(name="获取资讯类型", path="/configure/getNewsType", version="1.0.0")
     * @ApiDescription(value="获取资讯类型")
     * @Method(allow={POST})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getNewsType(): bool
    {
        $res = ConfigureService::getInstance()->getNewsType();
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取APP标题", path="/configure/getTitle", version="1.0.0")
     * @ApiDescription(value="获取APP标题")
     * @Method(allow={POST})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getTitle(): bool
    {
        $res = ConfigureService::getInstance()->getTitle();
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取启动页", path="/configure/getSplash", version="1.0.0")
     * @ApiDescription(value="获取启动页")
     * @Method(allow={POST})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getSplash(): bool
    {
        $res = ConfigureService::getInstance()->getSplash();
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @ApiDescription(value="获取出租房屋配置")
     * @Api(name="获取出租房屋配置", path="/configure/getRentType", version="1.0.0")
     * @Method(allow={POST})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getRentType(): bool
    {
        $res = ConfigureService::getInstance()->getRentType();
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }
}